package com.ljh.nio.c3;

import java.io.IOException;
import java.net.InetSocketAddress;
import java.nio.ByteBuffer;
import java.nio.channels.SocketChannel;

/**
 * @author: Themberfue
 * @date: 2025/5/26 19:50
 * @description:
 */
public class ClientWrite {
    public static void main(String[] args) throws IOException {
        SocketChannel sc = SocketChannel.open();

        sc.connect(new InetSocketAddress("localhost", 8080));

        int cnt = 0;
        while (true) {
            ByteBuffer buffer = ByteBuffer.allocate(1024 * 1024);
            cnt += sc.read(buffer);
            System.out.println(cnt);
            buffer.clear();
        }
    }
}
